package ericXie.com.command 
{

	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import ericXie.com.bussiness.LoadElementDelegate;
	import ericXie.com.interfaces.IDataResponder;
	import ericXie.com.model.MainModel;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	
	/**
	 * ...加载SWF元素
	 * @author EricXie
	 */
	public class LoadElementCommand implements ICommand, IDataResponder 
	{
		private var _model:MainModel = MainModel.getInstance();
		private var _delegate:LoadElementDelegate;
		
		public function LoadElementCommand() 
		{
			_delegate = new LoadElementDelegate(this);
		}
		public function execute(event:CairngormEvent):void
		{
			var readData:String= event.data as String;
		
			_delegate.readConfig(readData);
			
		}
		public function result(evt:Event):void
		{
			var loader:LoaderInfo = evt.target as LoaderInfo;
			_model.libElement = loader;
			
		}
		public function progress(evt:ProgressEvent):void {
			
		}
		public function fault(evt:IOErrorEvent):void
		{
			trace(evt.text)
		}
		
	}

}